package com.hstcs.input;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.hstcs.assets.Config;
import com.hstcs.components.HeroComponent;
import com.hstcs.game.God;
import com.hstcs.game.XGame;
import com.hstcs.screen.GameScreen;
import com.hstcs.systmes.MaogouSystem;


public class Hinput extends InputAdapter {
	
	public static Hinput instance = null;
	
	public static Hinput getInstance(){
		if(instance == null){
			instance = new Hinput();
		}
		return instance ;
	}
	
	Vector3 tmpTouchPos = new Vector3();

	@Override
	public boolean keyDown(int keycode) {
		// TODO Auto-generated method stub
		return super.keyDown(keycode);
	}

	@Override
	public boolean keyUp(int keycode) {
		// TODO Auto-generated method stub
		return super.keyUp(keycode);
	}

	@Override
	public boolean keyTyped(char character) {
		// TODO Auto-generated method stub
		return super.keyTyped(character);
	}

	@Override
	public boolean touchDown(int screenX, int screenY, int pointer, int button) {
		// TODO Auto-generated method stub
		
		tmpTouchPos.x = screenX;
		tmpTouchPos.y = screenY;
		XGame.getInstance().stage.getCamera().unproject(tmpTouchPos);
		if(God.getSystem(MaogouSystem.class).getMg(tmpTouchPos.x, tmpTouchPos.y, pointer)){
			System.out.println("touchDown========:" + pointer);
		}
	//	System.out.println("touchDown========down===:" + pointer);
		return super.touchDown(screenX, screenY, pointer, button);
	}

	@Override
	public boolean touchUp(int screenX, int screenY, int pointer, int button) {
		// TODO Auto-generated method stub
		
		God.getSystem(MaogouSystem.class).touchupMg(tmpTouchPos.x, tmpTouchPos.y, pointer);
		
		return super.touchUp(screenX, screenY, pointer, button);
	}

	@Override
	public boolean touchDragged(int screenX, int screenY, int pointer) {
		// TODO Auto-generated method stub
		tmpTouchPos.x = screenX;
		tmpTouchPos.y = screenY;
		XGame.getInstance().stage.getCamera().unproject(tmpTouchPos);
		God.getSystem(MaogouSystem.class).dragMg(tmpTouchPos.x, tmpTouchPos.y, pointer);
		
		
		return super.touchDragged(screenX, screenY, pointer);
	}

	@Override
	public boolean mouseMoved(int screenX, int screenY) {
		// TODO Auto-generated method stub
		return super.mouseMoved(screenX, screenY);
	}

	@Override
	public boolean scrolled(int amount) {
		// TODO Auto-generated method stub
		return super.scrolled(amount);
	}

}
